﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Brain.Logic3D.AI;
using Brain.Logic.AI;

namespace Brain
{
    public class AIData3D : IAIData
    {
        public BoundingFrustum ViewFrustum;

        public bool ShouldUpdate { get; set; }

        public ArtificialIntelligence3D AI;

        public AIInfo Info;

        public int Team { get; set; }

        public AIData3D(ArtificialIntelligence3D Ai, AIInfo AiInfo)
        {
            Ai.Tag1 = this;

            this.AI = Ai;
            ShouldUpdate = true;
            this.Info = AiInfo;

            ViewFrustum = new BoundingFrustum(Matrix.Identity);
        }

        public virtual void Update()
        {
            Vector3 height = new Vector3(0, Info.Info3D.Height, 0);
            Matrix View = Matrix.CreateLookAt(AI.WorldObject.Position + height,
                AI.WorldObject.Position + height + AI.WorldObject.RotationMatrix.Forward, AI.WorldObject.RotationMatrix.Up);
            Matrix Projection = Matrix.CreatePerspectiveFieldOfView(Info.Info3D.FieldOfView, 1.7f, 1, Info.Info3D.MaxDistance);

            ViewFrustum.Matrix = View * Projection;
        }
    }
}
